thread-priority
A simple library to control thread schedule policies and thread priority.
If your operating system isn't yet supported, please, create an issue.
Minimal Rust Compiler Version
Is 1.67
. If you need any help making it possible to compile with 1.56
please reach out, it
should be possible by just downgrading the rstest
version to 0.17
or lower (the code is
compatible).
Supported platforms
- Linux
- Android
- DragonFly
- FreeBSD
- OpenBSD
- NetBSD
- macOS
- iOS
- Windows
Examples
Minimal cross-platform examples
Setting current thread's priority to minimum:
use *;
The same as above but using a specific value:
use *;
use TryInto;
Windows-specific examples
Set the thread priority to the lowest possible value:
use *;
Set the ideal processor for the new thread:
use *;
Building a thread using the ThreadBuilderExt trait
use *;
use ThreadBuilderExt;
let thread = new
.name
.spawn_with_priority.unwrap;
thread.join;
Building a thread using the ThreadBuilder.
use *;
let thread = default
.name
.priority
.spawn.unwrap;
thread.join;
// Another example where we don't care about the priority having been set.
let thread = default
.name
.priority
.spawn_careless.unwrap;
thread.join;
Using ThreadExt trait on the current thread
use *;
assert!;
println!;
License
This project is licensed under the MIT license.